package com.shuqi.model;

import java.util.List;

import org.apache.http.message.BasicNameValuePair;

import android.content.Context;

import com.shuqi.common.MyTask;
import com.shuqi.common.Urls;
import com.shuqi.model.net.HttpRequest;
import com.shuqi.model.net.UrlManager;
import com.shuqi.model.net.listener.HttpRequestListener;
import com.shuqi.model.parse.parser.OfferWallItemParser;

/**
 * 推广墙详情页model
 * 
 * @author linyuren
 * 
 */
public class OfferWallItemModel extends ModelBase implements HttpRequestListener {

    private HttpRequest httpRequest;
    private Context context;
    /** 应用id */
    private String itemid = "";
    /** 区分是app还是game */
    private String from = "";

    public OfferWallItemModel(Context context) {
        this.context = context;
    }

    @Override
    public void action(int actionCode, Object object) {
        fireEvent(actionCode, object);
    }

    @Override
    public List<BasicNameValuePair> setParams() {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public String getRequestUrl() {
        return Urls.getOfferWallItemUrl(context, this.itemid, this.from);
    }

    @Override
    public void onDestroy() {
        if (httpRequest != null) {
            httpRequest.abort();
        }
    }

    @Override
    public void loadData(Object... objs) {
        this.itemid = (String) objs[0];
        this.from = (String) objs[1];

        this.httpRequest = new HttpRequest(context, getRequestUrl(), false, this);

        this.httpRequest.setDataParseAdapter(new OfferWallItemParser());
        MyTask.runInBackground(httpRequest, true);
    }

}
